# coding: utf8
#########################################################################
# uc_aria features database table auto initization
#########################################################################
# 
# TO DO:
#
# -Automatically add an admin user before feature initializers are 
# run and have this user assigned to all auto intitializers.
#
# File                        : models/z_uc_aria.py
# Corresponding controller    : none
#
# Organization                : TBD
# Author                      : Christopher Steel
# Copyright                   : 2010
# Contributors                :
# Last Changes                : 2010-02-11
#
# Description :
#
# models/z_uc_aria.py is automatically loaded and inserts preconfigured 
# values into the feature database. An similar initializer file is
# included with any uc compatible feature for auto installing the 
# feature.
#
# Currently the feature database includeds the following variables 
# which may be set by the feature developer as required:
#
# app_name, app_title, app_description, app_menu and app_active
#
##########################
# Intitializer Variables 
##########################
#
# To be set by the feature developer as required
#
#                                                      ## in db.feature corresponds to:
app_name = 'uc_multilingual'                                   # feature.name
app_title = 'language'                                     # feature.title
app_description = "uc_multilingual enables site multilingual features and menu" # feature.description
app_menu = 'settings'                                  # feature.menu, menu bar where item appears
## we should run some tests before setting to active, do we have all required components etc.
app_active = 'True'                                    # feature.active if true shows in menu

############################################
# retrieve our automated installers user_id
############################################
#
fnames_found='None'
rows=db(db.auth_user.first_name == fname).select(db.auth_user.ALL)
for row in rows:
    fnames_found = row.first_name
if fnames_found == 'automated':
    automated_user_id = row.id

#################################
# database entry initialization
#################################
#
# Description :
#
# Here we make our automatic database table in inserts based on the variables set
# in the Initializer Variables section above.
#
dbvalue='None'
rows=db(db.feature.name==app_name).select(db.feature.ALL)
for row in rows:
        dbvalue = row.name

if dbvalue == 'None':
    db.feature.insert(name=app_name,title=app_title,description=app_description,menu=app_menu,created_by=automated_user_id,active=app_active)
